package com.hmall.trade.listener;

import com.hmall.trade.service.IOrderService;
import lombok.RequiredArgsConstructor;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PathVariable;

/**
 * 支付状态监听器
 */
@Component
@RequiredArgsConstructor
public class PayStateListener {
    private final IOrderService orderService;

    @RabbitListener(bindings = @QueueBinding(
            value =@Queue("trade.pay.s.queue"),
            exchange = @Exchange(value = "pay.direct"),
            key = "pay.success"
    ))
    public void markOrderPaySuccess(Long orderId) {

        orderService.markOrderPaySuccess(orderId);
    }

}
